|
|
|
|
|
|
|
The Form_Deactivate() event occurs anytime a form loses focus to another form or application. You might use this event to deactivate buttons on a form so that a user has to give the form focus before clicking its buttons. This might help avoid events firing on one form when the user is currently on another form. Heres an example: |
|
|
|
 |
|
|
|
|
Private Sub Form_Deactivate()
cmdClose.Enabled = False
End Sub |
|
|
|
|
|
|
|
|
The QueryUnload() event fires when the user attempts to unload the form by clicking the Close button in the upper-right corner. This event may also be fired when you unload a form using the Unload Me statement in your Visual Basic code. The Unload Me statement is the same as the user closing the form through the Close button or the system menu. In this event, you have the option of canceling the unloading of this form. A common use of this event is to ask the user whether he or she wants to save any changed data prior to closing this form. |
|
|
|
|
|
|
|
|
This is the next-to-last event that occurs before a form is unloaded. You also have the option to cancel the unloading from happening in this event. This event is typically used to restore your Visual Basic application environment to the state it was when the form was first loaded. |
|
|
|
|
|
|
|
|
The Form_Terminate() event is the last event to fire when a form is unloaded. This event is typically used to clean up any form variables that may have been initialized in the Form_Initialize() event. |
|
|
|
|
|
|
|
|
There are events associated with label controls; however, in most instances, you will not use them. Labels are generally just used to display data to the user and are not used as an event mechanism. The most common events you may use on labels are the Change and Click() events. |
|
|
|
|
|